package com.example.task1.ui.AllService.law;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.task1.R;
import com.example.task1.application.MyApplication;
import com.example.task1.base.BaseActivity;
import com.example.task1.bean.LawListBean;
import com.example.task1.bean.LawSortListBean;
import com.example.task1.http.Api;
import com.example.task1.util.ApiResp;
import com.example.task1.util.CallBack;

import retrofit2.Call;

public class LawSortListActivity extends BaseActivity {

    private int id;
    private RecyclerView rvList;
    private LawSortListAdapter lawListAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_law_sort_list);
        id = getIntent().getIntExtra("id", 0);
        initView();
        setAdApter();
        initData();
    }

    private void setAdApter() {
        lawListAdapter = new LawSortListAdapter(this);
        LinearLayoutManager Manager = new LinearLayoutManager(this);
        rvList.setAdapter(lawListAdapter);
        rvList.setLayoutManager(Manager);
    }

    private void initData() {
        Call<ApiResp> call = Api.api().get(MyApplication.TOKEN, "/prod-api/api/lawyer-consultation/lawyer/list?legalExpertiseId=" + id);
        Api.send(call, LawSortListBean.class, new CallBack<LawSortListBean>() {
            @Override
            public void success(LawSortListBean data) {
                lawListAdapter.setData(data.getRows());
            }

            @Override
            public void error(String msg) {

            }
        });
    }

    @Override
    public String getMyTitle() {
        return "律师";
    }

    private void initView() {
        rvList = findViewById(R.id.rv_list);
    }
}